
import { _decorator, Component, Node, Button } from 'cc';
import { Constants } from '../data/Constants';
import { CustomEventListener } from '../data/CustomEventListener';
import { BattleManager } from '../managers/BattleManager';
import { UIManager } from './UIManager';
const { ccclass, property } = _decorator;

@ccclass('FailPanel')
export class FailPanel extends Component {
    @property({
        type: Button,
        displayOrder: 1,
    })
    reloadBtn: Button = null!;
    //显示失败界面
    public show() {
        console.log('显示失败界面')
        // this.node.active = true
    }
    //隐藏失败界面
    public hide() {
        console.log('隐藏失败界面')
        // this.node.active = false
    }

    start() {
        this.reloadBtn.node.on(Node.EventType.TOUCH_START, this._restartBtnClick, this)
    }

    private _restartBtnClick = () => {
        //回到主界面
        UIManager.hideDialog(Constants.UIPage.failPanel)
        UIManager.showDialog(Constants.UIPage.mainPanel)
        CustomEventListener.dispatchEvent(Constants.EventName.GAME_RESTART)
    }
}
